﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace VoluntariadoWindows8Backend
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //System.Uri myUri = new System.Uri(string.Format("http://ws.voluntariado.org:10050/VoluntariadoMobile/getOportunidades?lat={0}&lon={1}&radio={2}", 40.3, -3.2, 100000));
                System.Uri myUri = new System.Uri("http://localhost:10050/Voluntariadow8/getCategorias");
                HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(myUri);
                NetworkCredential myCred = new NetworkCredential("demo", "demo");
                CredentialCache myCredentialCache = new CredentialCache();
                myCredentialCache.Add(myUri, "Basic", myCred);
                HttpWRequest.Credentials = myCredentialCache;

                HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();
                Stream strm = HttpWResponse.GetResponseStream();
                StreamReader sr = new StreamReader(strm);
                string sText = sr.ReadToEnd();
                Console.WriteLine("Response: {0}", sText);
                strm.Close();
                sr.Close();

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }
    }
}
